<?php


class DomainAction extends UserAction{
	private $db;
	//配置
	/*
	public function index(){
		$other=M('Other')->where(array('token'=>session('token')))->find();
		if(IS_POST){
			if($other==false){
				$this->all_insert('Other','/index');
			}else{
				$_POST['id']=$other['id'];
				$this->all_save('Other','/index');
			}
		}else{
			//dump($other);
			$this->assign('other',$other);
			$this->display();
		}
	}
	*/
	public function index(){
		//如果没有就插入 如果有就更新
		$this->db = M('Web_domain');
		$domain = $this->db->where(array('token'=>session('token')))->find();
		if(IS_POST){
			
			$data['domain']=$_POST['domain'];
			$data['token']=session('token');
			$data['uid'] = session('uid');
			$data['status'] = 1;
			
			if($data['domain']&&$data['token']&&$data['uid']&&$data['status']){
				if($domain==false){
					$this->db->add($data);
					$this->success('域名注册成功');
					exit();
				}else{
					$data['id']=$domain['id'];
					$this->db->save($data);
					$this->success('域名修改成功 ');
					exit();
				}
			}else{
				$this->error('信息不全');
			}
		}else{
			$this->assign('domain',$domain);
		}
		$this->display();
	}

}

?>